// https://leetcode.cn/problems/construct-the-rectangle/
// Created by ade on 2022/8/8.
//
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

class Solution {
public:
    // 暴力
    vector<int> constructRectangle1(int area) {
        vector<int> res = {area, 1};
        if (area <= 3) return res;
        for (int i = area / 2; i >= 2; i--) {
            if (area % i != 0) continue;
            if (i >= area / i && i - area / i < res[0] - res[1]) {
                res[0] = i;
                res[1] = area / i;
            }
            if (res[0] <= res[1]) {
                break;
            }
        }
        return res;
    }

    vector<int> constructRectangle(int area) {
        int w = sqrt(area);
        while (area % w) {
            w--;
        }
        return {area / w, w};
    }
};

int main() {

}